package com.sgdh.netty.constant;


public class MouseOperation implements IMouseOperation {
	private String message;
	private boolean dragging;
	private ClientNetty netty;

	public MouseOperation(ClientNetty netty) {
		message = new String();
		dragging = false;
		this.netty = netty;
	}

	@Override
	public int leftClick() {
		String commond = String.format("%20s", "leftClick");
		String panelId= String.format("%20s", netty.getPanelId());
		message = commond+panelId;
		netty.getChannel().writeAndFlush(message + '\n');
		return 0;
	}

	@Override
	public int leftDoubleClick() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int leftDown() {
		if (dragging == false) {
			dragging = true;
			String commond = String.format("%20s", "leftDown");
			String panelId= String.format("%20s", netty.getPanelId());
			message = commond+panelId;
			netty.getChannel().writeAndFlush(message + '\n');
		}
		return 0;
	}

	@Override
	public int leftUp() {
		dragging = false;
		String commond = String.format("%20s", "leftUp");
		String panelId= String.format("%20s", netty.getPanelId());
		message = commond+panelId;
		netty.getChannel().writeAndFlush(message + '\n');
		return 0;
	}

	@Override
	public int rightClick() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int rightDown() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int rightUp() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int middleClick() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int middleDown() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int middleUp() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int wheel(int rotation) {
		String commond = String.format("%20s", "wheel");
		String panelId= String.format("%20s", netty.getPanelId());
		String Number = String.format("%10d", rotation);
		message = commond+panelId+Number;
		netty.getChannel().writeAndFlush(message + '\n');
		return 0;
	}

	@Override
	public int moveTo(int x, int y) {
		String commond = String.format("%20s", "moveTo");
		String panelId= String.format("%20s", netty.getPanelId());
		String X = String.format("%10d", x);
		String Y = String.format("%10d", y);
		message = commond+panelId+X+Y;
		netty.getChannel().writeAndFlush(message + '\n');
		return 0;
	}

}
